#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>

unsigned int My_Alarm(unsigned int seconds) {
    struct itimerval oldit, myit = {{0, 0}, {0, 0}};
    myit.it_value.tv_sec = seconds;

    setitimer(ITIMER_REAL, &myit, &oldit);

    printf("tv_sec = %ld, tv_usec = %ld\n", oldit.it_value.tv_sec, oldit.it_value.tv_usec
           );

    return oldit.it_value.tv_sec;
}

int main()
{
    int ret = 0;
    
    ret = My_Alarm(5);
    printf("ret = %d\n", ret);

    sleep(3);
    ret = My_Alarm(3);
    printf("ret = %d\n", ret);

    while(1) {
        printf("Hello\n");
        sleep(1);
    }


    return 0;
}

